PyVista is…
“VTK for humans”: a high-level API to the Visualization Toolkit (VTK)
mesh data structures and filtering methods for spatial datasets
3D plotting made simple and built for large/complex data geometries
PyVista is a helper module for the Visualization Toolkit (VTK) that takes a different approach on interfacing with VTK through NumPy and direct array access. This package provides a Pythonic, well-documented interface exposing VTK’s powerful visualization backend to facilitate rapid prototyping, analysis, and visual integration of spatially referenced datasets.
This module can be used for scientific plotting for presentations and research papers as well as a supporting module for other mesh dependent Python modules.
Share this project on Twitter:
Want to test-drive PyVista? Check out our live examples on MyBinder:
Brief Examples¶
Here are some brief interactive examples that demonstrate how you might want to use PyVista:
Maps and Geoscience¶
Download the surface elevation map of Mount St. Helens and plot it.
from pyvista import examples
mesh = examples.download_st_helens()
warped = mesh.warp_by_scalar('Elevation')
warped.plot(cmap='spectral')
Finite Element Analysis¶
Plot the ‘X’ component of elastic stress of a 3D notch specimen.
from pyvista import examples
mesh = examples.download_notch_stress()
mesh.plot(scalars='Nodal Stress', component=0, cmap='Turbo',
cpos='xy', show_scalar_bar=False)
Simple Point Cloud with Numpy¶
Easily integrate with NumPy and create a variety of geometries and plot them. You could use any geometry to create your glyphs, or even plot the points directly.
import numpy as np
import pyvista
point_cloud = np.random.random((100, 3))
pdata = pyvista.PolyData(point_cloud)
pdata['orig_sphere'] = np.arange(100)
# create many spheres from the point cloud
sphere = pyvista.Sphere(radius=0.02)
pc = pdata.glyph(scale=False, geom=sphere)
pc.plot(background='black', cmap='Reds', show_scalar_bar=False)
Plot a Spline¶
Generate a spline from an array of NumPy points.
import numpy as np
import pyvista
# Make the xyz points
theta = np.linspace(-10 * np.pi, 10 * np.pi, 100)
z = np.linspace(-2, 2, 100)
r = z**2 + 1
x = r * np.sin(theta)
y = r * np.cos(theta)
points = np.column_stack((x, y, z))
spline = pyvista.Spline(points, 1000).tube(radius=0.1)
# done here to get it to render online
line = spline.cast_to_unstructured_grid().extract_surface()
line.plot(show_scalar_bar=False)
Boolean Operations on Meshes¶
Combine two meshes to create a manifold mesh.
import pyvista
import numpy as np
def make_cube():
x = np.linspace(-0.5, 0.5, 25)
grid = pyvista.StructuredGrid(*np.meshgrid(x, x, x))
return grid.extract_surface().triangulate()
# Create example PolyData meshes for boolean operations
sphere = pyvista.Sphere(radius=0.65, center=(0, 0, 0))
cube = make_cube()
# Perform the union
union = sphere.boolean_union(cube)
union.plot(color='darkgrey')
Translating¶
The recommended way for new contributors to translate PyVista’s documentation is to join the translation team on Transifex.
There is a pyvista translation page for pyvista (master) documentation.
Login to transifex service.
Go to pyvista translation page.
Click
Request languageand fill form.Wait acceptance by transifex pyvista translation maintainers.
(After acceptance) Translate on transifex.
You can see the translated document in Read The Docs.
Details can be found here: https://docs.transifex.com/getting-started-1/translators
Status¶
Deployment |
||
Build Status |
||
Metrics |
||
Activity |
||
GitHub |
||
Citation |
||
License |
||
Community |
